package com.fast.config;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.concurrent.TimeUnit;

@Slf4j
@Getter
@Setter
@Component
//@RefreshScope
public class TestRefreshConfig {

    @Value("${spring.application.name}")
    private String name;
//    @Value("${spring.dynamic.thread-pool.enable}")
    private String enable;

    @PostConstruct
    public void TestRefreshConfig() {
        TestRefreshConfig that = this;
        new Thread(() -> {
            while (true) {
                log.info("inner enable={} that.hashcode={}", enable, that.hashCode());
                log.info("inner code={} that.hashcode={}", name, that.hashCode());
                try {
                    TimeUnit.SECONDS.sleep(5);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }).start();
    }
}
